package logic

import (
	"api/model/mysql"
	"context"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type InfoHouseLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewInfoHouseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoHouseLogic {
	return &InfoHouseLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *InfoHouseLogic) InfoHouse(in *house.InfoHouseRequest) (*house.InfoHouseResponse, error) {
	// todo: add your logic here and delete this line

	var h mysql.House
	mysql.DB.Where("id=?", in.HouseId).Find(&h)

	return &house.InfoHouseResponse{
		HouseCity:    h.HouseCity,
		HouseAddress: h.HouseAddress,
		HouseBuild:   h.HouseBuild,
		HouseFloor:   h.HouseFloor,
		HouseArea:    int64(h.HouseArea),
		HousePrice:   float32(h.HousePrice),
		HouseAuthor:  h.HouseAuthor,
		HouseStatus:  int64(h.HouseStatus),
	}, nil
}
